package jaux.tank.bean.entity.system;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * 
 * 单位部门
 *  
 */
@Entity
@Table(name = "t_sys_dept")
public class Dept extends EntityWithObjectId{
	
	@Basic
	@Column(name = "num")
    private Integer num;

	@ManyToOne(fetch = FetchType.LAZY,optional = true)
    private Dept parentDept;
	@Basic
	@Column(name = "simplename")
    private String simplename;
	@Basic
	@Column(name = "fullname")
    private String fullname;
	@Basic
	@Column(name = "tips")
    private String tips;
    @Basic
    @Column(name = "version")
    private Integer version;

    public String getPid() {
    	if(parentDept!=null)
    		return parentDept.getId();
    	return null;
    }
    public void setPid(String pid) {
    	if(parentDept==null) {
    		this.parentDept=new Dept();
    	}
    	this.parentDept.setId(pid);
    }
    
    public Integer getNum() {
        return num;
    }

    public void setNum(Integer num) {
        this.num = num;
    }

    public String getSimplename() {
        return simplename;
    }

    public void setSimplename(String simplename) {
        this.simplename = simplename;
    }

    public String getFullname() {
        return fullname;
    }

    public void setFullname(String fullname) {
        this.fullname = fullname;
    }

    public String getTips() {
        return tips;
    }

    public void setTips(String tips) {
        this.tips = tips;
    }

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }
    
    public Dept getParentDept() {
		return parentDept;
	}

	public void setParentDept(Dept parentDept) {
		this.parentDept = parentDept;
	}
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Dept tSysDept = (Dept) o;

        if (id != null ? !id.equals(tSysDept.id) : tSysDept.id != null) return false;
        if (num != null ? !num.equals(tSysDept.num) : tSysDept.num != null) return false;
        if (parentDept != null ? !parentDept.equals(tSysDept.parentDept) : tSysDept.parentDept != null) return false;
        if (simplename != null ? !simplename.equals(tSysDept.simplename) : tSysDept.simplename != null) return false;
        if (fullname != null ? !fullname.equals(tSysDept.fullname) : tSysDept.fullname != null) return false;
        if (tips != null ? !tips.equals(tSysDept.tips) : tSysDept.tips != null) return false;
        if (version != null ? !version.equals(tSysDept.version) : tSysDept.version != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (num != null ? num.hashCode() : 0);
        result = 31 * result + (parentDept != null ? parentDept.hashCode() : 0);
        result = 31 * result + (simplename != null ? simplename.hashCode() : 0);
        result = 31 * result + (fullname != null ? fullname.hashCode() : 0);
        result = 31 * result + (tips != null ? tips.hashCode() : 0);
        result = 31 * result + (version != null ? version.hashCode() : 0);
        return result;
    }

	
}
